/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package jhelper;

import java.io.*;
import java.text.SimpleDateFormat;
import java.util.*;
/**
 *
 * @author Administrator
 */
public class Notices {
    private Reader f;
   public String getTodayName(){
       
       Date date=new Date();
       SimpleDateFormat formatter=new SimpleDateFormat("yyyy-mm-dd");
       String dateString=formatter.format(date);
       return dateString;
   }
   
      public String getTomorrowName(){
        Date date = new Date();
        Calendar calendar = new GregorianCalendar();
        calendar.setTime(date);        
        calendar.add(calendar.DATE, 1);
        date = calendar.getTime();
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        String dateString = formatter.format(date);
        return dateString;
    }
       public void getTodayNotices() throws FileNotFoundException, IOException{
           File file=new File("notice/"+getTodayName()+".txt");
           if(file.exists())
               //<editor-fold defaultstate="collapsed" desc="comment">
               FileReader f=new FileReader(file);
           //</editor-fold>
          BufferedReader br=new BufferedReader(f);
          String temp=null;
          while((temp=br.readLine())!=null){
           System.out.println("temp");
          }
           
       } else{   
       System.out.println("今天没有什么特别要提醒的");
}
       public boolean setTomorrowNotices(String notice) throws FileNotFoundException, IOException{
           File file=new File("notice");
           if(!file.exists()){
               file.mkdir();
           }
           file=new File("notice/"+getTomorrowNam()+".txt");
           if(!file.exists()){
               file.createNewFile();
           }
         FileOutputStream f=new FileOutputStream(file,true);
        PrintWriter p=new PrintWriter(f,true);
        p.print(notice);
        System.out.print("成功添加了一条明天的备忘信息");
          return true;
        
       }
       public static void main(String[] args) throws IOException {
        Notices n=new Notices();
        String dateString=n.getTodayName();
        System.out.print(dateString);
        String tomorrowString=n.getTomorrowName();
        System.out.print(tomorrowString);
        //n.setTomorrowNotices("11:40下课，抢位置去"）;
        n.setTomorrowNotices("明天要逛街，取钱去");
    }

    private String getTomorrowNam() {
        throw new UnsupportedOperationException("Not yet implemented");
    }
}
